<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Tem
 *
 * @author Zoila
 */
class Team extends AppModel {
    
    public $validate = array(
        'name' => array(
            'rule' => 'notEmpty'
        )
    );
    
//    public $belongsTo = array(
//        'Organization' => array(
//            'className'    => 'Organization',
//            'foreignKey'   => 'organizartion_id'
//        )
//   );

    public $hasMany = array(
        'Member' => array(
            'className'  => 'Member',
            'foreignKey' => 'team_id'
        )
    );
    
    public $hasAndBelongsToMany = array(
        'Project' =>
            array(
                'className'              => 'Project',
                'joinTable'              => 'project_teams',
                'foreignKey'             => 'team_id',
                'associationForeignKey'  => 'project_id',
                'unique'                 => true,
                'conditions'             => '',
                'fields'                 => '',
                'order'                  => '',
                'limit'                  => '',
                'offset'                 => '',
                'finderQuery'            => '',
                'deleteQuery'            => '',
                'insertQuery'            => ''
            )
    );
    public function isOwnedBy($st, $user) {
        return $this->field('id', array('id' => $st, 'creator_id' => $user)) === $st;
    }
}

?>
